//
//  HSCLogCell.m
//  SSC
//
//  Created by 红沙尘 on 17/6/6.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "HSCLogCell.h"

@interface HSCLogCell ()
{
    __weak IBOutlet UILabel *urlLabel;
    __weak IBOutlet UILabel *parameterLabel;
    __weak IBOutlet UILabel *resultLabel;
    __weak IBOutlet UILabel *dateLabel;
    
    __weak IBOutlet UIButton *stateBtn;
}

@end

@implementation HSCLogCell




- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)loadWithDict:(NSDictionary *)dict {
    
    self.logDict = dict;
    
    dateLabel.text = [NSString stringWithFormat:@"时间:%@",dict[@"date"]];
    urlLabel.text = [NSString stringWithFormat:@"url:%@",dict[@"url"]];
    parameterLabel.text = [NSString stringWithFormat:@"参数:%@",dict[@"apiparam"]];
    resultLabel.text = [NSString stringWithFormat:@"结果:%@",dict[@"result"]];
}

- (void)loadWithStateModel:(LogStateModel *)logModel {
    
    self.stateModel = nil;
    self.stateModel = logModel;
    
    if (logModel.show) {
        urlLabel.numberOfLines = 3;
        [stateBtn setTitle:@"展开" forState:UIControlStateNormal];
    } else {
        urlLabel.numberOfLines = 0;
        [stateBtn setTitle:@"收起" forState:UIControlStateNormal];
    }
    
    parameterLabel.numberOfLines = urlLabel.numberOfLines;
    resultLabel.numberOfLines = urlLabel.numberOfLines;
}

- (IBAction)buttonPressed {
    self.stateModel.show = !self.stateModel.show;
    if ([self.logDelegate respondsToSelector:@selector(modelStateChanged:)]) {
        [self.logDelegate modelStateChanged:self];
    }
}

@end

@implementation LogStateModel


@end
